home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Linux Cubed Series 8: LINUX Games
/
Linux Cubed Series 8 - LINUX Games.iso
/
games
/
x11
/
strategy
/
shanghai.000
/
shanghai
/
shanghai-1.0
/
game.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-05-31
|
22KB
|
742 lines
#include <memory.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include "forms.h"
#include "board.h"
#include "game.h"
#include "mapdata.h"
/* This parameter allows for tuning the performance of the depthscan
algorithm by selecting between different heuristics; PRIORITY == 1
seems to work best, but it is probably worthwhile to think a
little more about good heuristics... */
#define PRIORITY /* 0 */ 1 /* 2 */ /* 3 */
/* Select different methods for drawing suggestings; currently
DRAWSUGGEST == 0 is fasted, but that might change, if draw_area()
can be optimized */
#define DRAWSUGGEST 0 /* 1 */
int default_isfastgame = 0;
static __inline__ int chk(unsigned char *occ,unsigned char *arr)
{
int i;
for (i = 0; arr[i] != NIL; i++)
if (occ[arr[i]] != NIL) return(arr[i]);
return(NIL);
}
static __inline__ int tile_is_removable(unsigned char *occ,int tile)
{
register unsigned char top;
return(occ[tile] != NIL &&
(((top = board[tile].top) == NIL || occ[top] == NIL) &&
(chk(occ,board[tile].left) == NIL ||
chk(occ,board[tile].right) == NIL)));
}
static __inline__ int match_count(unsigned char *occ,unsigned char *lookup,
unsigned char *inverse)
{
unsigned char i,j,k,l;
int count = 0,tmpcount;
if (inverse)
memset(inverse,NIL,sizeof(unsigned char)*144);
for (i = 144/4; i--;) {
tmpcount = 0;
l = NIL;
for (j = 4; j--;) {
k = lookup[4*i+j];
if (tile_is_removable(occ,k)) {
if (l != NIL && inverse) {inverse[l] = 1; inverse[k] = 1;}
l = k;
tmpcount++; } }
if (tmpcount >= 2)
count += tmpcount-1; }
return(count);
}
static int find_unambiguous(BoardRec *board_rec,unsigned char *occ,
unsigned char *sel0,unsigned char *sel1)
{
unsigned char * const lookup = board_rec->lookup;
unsigned char i,j,k,isOcc;
int count;
int remain = 0,m = NIL,n = NIL;
*sel0 =
*sel1 = NIL;
for (i = 144/4; i--; ) {
count = isOcc = 0;
for (j = 4; j--; ) {
k = lookup[4*i+j];
if (occ[k] == NIL || tile_is_removable(occ,k)) {
if (occ[k] != NIL)
isOcc++;
count++; } }
if (isOcc >= 2) {
remain += isOcc;
if (count == 4)
for (j = 4; j--; ) {
k = lookup[4*i+j];
if (occ[k] != NIL) if (*sel0 == NIL)
*sel0 = k;
else {
*sel1 = k; return(1); } }
else if (isOcc == 2 && remain == 2)
for (j = 4; j--; ) {
k = lookup[4*i+j];
if (tile_is_removable(occ,k))
if (m == NIL) m = k;
else n = k; } } }
if (remain == 2) {
*sel0 = m; *sel1 = n;
return(1); }
return(0);
}
#if PRIORITY == 1 || PRIORITY == 3
static unsigned char const * cur_weight = NULL;
#if PRIORITY == 3
static int (*pri_comp)(const void *,const void *) = NULL;
static int pricount = 0;
static int pri_comp0(const void *pri1,const void *pri2)
{
return((int)*(unsigned char *)pri1 - (int)*(unsigned char *)pri2);
}
static int pri_comp2(const void *pri1,const void *pri2)
{
return((int)*(unsigned char *)pri1 - (int)*(unsigned char *)pri2);
}
static int pri_comp1(const void *pri1,const void *pri2)
#else
#endif
#endif
#if PRIORITY != 3
static int pri_comp(const void *pri1,const void *pri2)
#endif
{
#if PRIORITY == 0
return((int)*(unsigned char *)pri1 - (int)*(unsigned char *)pri2);
#else
return(16*cubic((int)((unsigned char *)pri1)[0]
-(int)((unsigned char *)pri2)[0])
+(int)cur_weight[((unsigned char *)pri1)[1]]
+(int)cur_weight[((unsigned char *)pri1)[2]]
-(int)cur_weight[((unsigned char *)pri2)[1]]
-(int)cur_weight[((unsigned char *)pri2)[2]]);
#endif
}
static void depth_scan_findpairs(BoardRec *board_rec)
{
DepthScanRec * const depthscan = &board_rec->depthscan;
unsigned char * const occ = depthscan->occ;
unsigned char * const stack = depthscan->stack;
unsigned char * const lookup = board_rec->lookup;
#if PRIORITY == 2 || PRIORITY == 3
unsigned char * const weight = board_rec->weight;
#endif
int sp = depthscan->sp,pp;
int pair,sel1,sel2;
int tile1,tile2;
int pri;
for (pair = 144/4; pair--;)
for (sel1 = 4; --sel1;) {
tile1 = lookup[4*pair+sel1];
if (tile_is_removable(occ,tile1))
for (sel2 = sel1; sel2--;) {
tile2 = lookup[4*pair+sel2];
if (tile_is_removable(occ,tile2)) {
occ[tile1] = occ[tile2] = NIL;
if (sp < sizeof(depthscan->stack)-3 &&
((pri = match_count(occ,lookup,NULL)) != 0 ||
depthscan->remain == 2)) {
#if PRIORITY == 2 || PRIORITY == 3
#if PRIORITY == 3
if (pri_comp == pri_comp2)
#endif
pri = 2*cubic(pri)+((int)weight[tile1]+(int)weight[tile2])/8-
sqr((int)weight[tile1]-(int)weight[tile2])/128+32;
stack[sp++] = pri > 255 ? 255 : pri < 0 ? 0 : pri;
#else
stack[sp++] = pri;
#endif
stack[sp++] = tile1;
stack[sp++] = tile2; }
occ[tile1] = 4*pair+sel1;
occ[tile2] = 4*pair+sel2; } } }
if (sp != (pp = depthscan->pp)) {
int i,j;
#if PRIORITY == 1 || PRIORITY == 3
cur_weight = board_rec->weight;
#endif
qsort(stack+pp,(sp-pp)/3,3,pri_comp);
for (i = sp, j = sp = pp; j < i; j += 3) {
stack[sp++] = stack[j+1];
stack[sp++] = stack[j+2]; } }
depthscan->sp = sp;
return;
}
static void depth_scan_update_ideal(BoardRec *board_rec)
{
DepthScanRec * const depthscan = &board_rec->depthscan;
unsigned char * const occ = depthscan->occ;
unsigned char * const stack = depthscan->stack;
unsigned char * const lookup = board_rec->lookup;
unsigned char * const ideal = board_rec->ideal;
unsigned char * const weight = board_rec->weight;
unsigned char * const history = board_rec->history;
unsigned char tile;
int sp = depthscan->sp;
int remain = depthscan->remain;
while (sp != 0) {
occ[ideal[remain++] = stack[sp-5]] = stack[sp-3];
occ[ideal[remain++] = stack[sp-6]] = stack[sp-4];
sp = stack[sp-1] + 256*stack[sp-2]; }
depthscan->remain = remain;
while (remain < 144) {
ideal[remain++] = lookup[history[142-remain]];
ideal[remain++] = lookup[history[144-remain]]; }
for (tile = 144; tile--;)
weight[ideal[tile]] = tile+1;
depthscan->sp =
depthscan->pp = 0;
return;
}
enum dsStatus depth_scan(BoardRec *board_rec)
{
DepthScanRec * const depthscan = &board_rec->depthscan;
unsigned char * const occ = depthscan->occ;
unsigned char * const stack = depthscan->stack;
int sp;
int pp;
int remain;
unsigned char tile1,tile2;
if (depthscan->status != dsBusy)
return(depthscan->status == dsSuccessSelected ?
dsSuccess : depthscan->status);
depth_scan_findpairs(board_rec);
sp = depthscan->sp;
pp = depthscan->pp;
remain = depthscan->remain;
next_branch:
while (pp != 0 && sp == pp) {
#if PRIORITY == 3
#define PRSWITCH 8192
if ((++pricount % PRSWITCH) == 0) {
printf("switch\n");
if (pricount == 3*PRSWITCH) {pricount = 0; pri_comp = pri_comp0; }
else if (pricount == 2*PRSWITCH) pri_comp = pri_comp2;
else pri_comp = pri_comp1; }
#endif
remain += 2;
occ[stack[sp-5]] = stack[sp-3];
occ[stack[sp-6]] = stack[sp-4];
pp = stack[sp-1] + 256*stack[sp-2];
sp -= 6; }
if (sp != 0)
if (sp < sizeof(depthscan->stack)-6+2) {
stack[sp++] = occ[stack[sp-2]];
stack[sp++] = occ[stack[sp-2]];
stack[sp++] = pp/256;
stack[sp++] = pp%256;
occ[stack[sp-5]] =
occ[stack[sp-6]] = NIL;
pp = sp;
remain -= 2;
while (sp < sizeof(depthscan->stack)-6 &&
find_unambiguous(board_rec,occ,&tile1,&tile2)) {
stack[sp++] = tile1;
stack[sp++] = tile2;
stack[sp++] = occ[tile1];
stack[sp++] = occ[tile2];
stack[sp++] = pp/256;
stack[sp++] = pp%256;
pp = sp;
occ[tile1] =
occ[tile2] = NIL;
remain -= 2; }
if (remain == 0)
depthscan->status = dsSuccess; }
else {
sp -= 2;
goto next_branch; }
else
depthscan->status = remain ? dsFail : dsSuccess;
depthscan->sp = sp;
depthscan->pp = pp;
depthscan->remain = remain;
if (depthscan->status == dsSuccess)
depth_scan_update_ideal(board_rec);
if (depthscan->status != dsBusy)
update_info_box(board_rec);
return(depthscan->status);
}
static int is_board_ideal(BoardRec *board_rec)
{
unsigned char * const lookup = board_rec->lookup;
unsigned char * const ideal = board_rec->ideal;
unsigned char * const weight = board_rec->weight;
unsigned char * const history = board_rec->history;
int i,j,remain,hist;
unsigned char tile1,tile2,occ[144];
if ((remain = board_rec->remain) == 0)
return(1);
hist = board_rec->histpos;
memcpy(occ,board_rec->occ,sizeof(occ));
for (i = 144,j = 1; j && i-- > remain; )
if (occ[ideal[i]] != NIL)
j = 0;
if (!j) {
while (find_unambiguous(board_rec,occ,&tile1,&tile2)) {
remain -= 2;
history[hist++] = occ[tile1];
history[hist++] = occ[tile2];
occ[tile1] = occ[tile2] = NIL; }
for (i = 144; i-- > remain; )
if (occ[ideal[i]] != NIL)
return(0); }
while (remain < 144) {
ideal[remain++] = lookup[history[142-remain]];
ideal[remain++] = lookup[history[144-remain]]; }
for (tile1 = 144; tile1--;)
weight[ideal[tile1]] = tile1+1;
return(1);
}
static void depth_scan_initialize(BoardRec *board_rec)
{
DepthScanRec * const depthscan = &board_rec->depthscan;
#if PRIORITY == 3
pricount = 0;
pri_comp = pri_comp0;
#endif
memcpy(depthscan->occ,board_rec->occ,sizeof(depthscan->occ));
depthscan->sp =
depthscan->pp = 0;
depthscan->remain = board_rec->remain;
if (depthscan->remain == 144 || is_board_ideal(board_rec))
depthscan->status = dsSuccess;
else
depthscan->status = dsBusy;
return;
}
static int valid_pos(unsigned char *occ,int i)
{
int j;
if (occ[i] != NIL)
return(0);
switch (i) {
case 0:
return(occ[1] != NIL);
case 1:
return (occ[3] != NIL && occ[4] != NIL);
case 86:
return(occ[61] != NIL && occ[65] != NIL &&
occ[81] != NIL && occ[85] != NIL);
case 143:
return(occ[140] != NIL && occ[141] != NIL);
default:
break; }
if (board[i].bottom != NIL && occ[board[i].bottom] == NIL)
return(0);
for (j = i; j != NIL; j = board[j].left[0])
if (occ[j] != NIL)
if (board[i].left[0] != j)
return(0);
else
break;
for (j = i; j != NIL; j = board[j].right[0])
if (occ[j] != NIL)
if (board[i].right[0] != j)
return(0);
else
break;
return(1);
}
static int neighbor(unsigned char *occ,int pos1,int pos2)
{
if (board[pos1].left[0] == pos2 ||
board[pos1].right[0] == pos2) {
if (board[pos1].left[0] == pos2) {
if (chk(occ,board[pos1].right) != NIL ||
chk(occ,board[pos2].left) != NIL)
return(1); }
else if (chk(occ,board[pos1].left) != NIL ||
chk(occ,board[pos2].right) != NIL)
return(1); }
if (board[pos1].top == pos2 ||
board[pos2].top == pos1)
return(1);
switch (pos1) {
case 0:
return(pos2 == 1 || pos2 == 3 || pos2 == 4);
case 1:
return(pos2 == 3 || pos2 == 4);
case 3: case 4:
return(pos2 == 1 || pos2 == 0);
case 140: case 141:
return(pos2 == 143);
case 143:
return(pos2 == 140 || pos2 == 141);
default:
break; }
return(0);
}
static void initialize_new_board(long seed,unsigned char *occ,
unsigned char *ideal,unsigned char *weight,
unsigned char *lookup)
{
int ob,tile1,tile2,count,obcount;
int obs[5],nloop,inc;
unsigned char *id;
srand(seed);
loop:
nloop = 0;
memset(occ,NIL,sizeof(unsigned)*144);
memset(obs,0,sizeof(obs));
id = ideal;
for (obcount = 0; obcount < 144/2; obcount++) {
ob = 2*(rand()%(144/4))+(obcount >= 144/4);
inc = rand() & 1 ? 2 : -2;
for (;;) {
if (obs[ob/16] & (1 << (ob % 16))) {
if ((ob += inc) >= 144/2) ob -= 144/2;
else if (ob < 0) ob += 144/2; }
else
break; }
obs[ob/16] |= (1 << (ob % 16));
ob *= 2;
retry:
tile1 = rand() % 144;
inc = rand() & 1 ? 1 : -1;
count = 0;
while (!valid_pos(occ,tile1)) {
if ((tile1 += inc) >= 144) tile1 = 0;
else if (tile1 < 0) tile1 = 143;
if (count++ == 144)
goto loop; }
occ[tile1] = ob;
tile2 = rand() % 144;
inc = rand() & 1 ? 1 : -1;
count = 0;
while (tile1 == tile2 || !valid_pos(occ,tile2)) {
if ((tile2 += inc) >= 144) tile2 = 0;
else if (tile2 < 0) tile2 = 143;
if (count++ == 144)
goto loop; }
if (neighbor(occ,tile1,tile2)) {
occ[tile1] = NIL;
if (nloop)
goto loop;
nloop = 1;
goto retry; }
nloop = 0;
occ[tile2] = ob+1;
lookup[ob] = tile1;
lookup[ob+1] = tile2;
*id++ = tile1;
*id++ = tile2; }
for (tile1 = 144; tile1--;)
weight[ideal[tile1]] = tile1+1;
return;
}
BoardRec *initialize_board_rec(FD_board *board,BoardRec *board_rec,int seed)
{
int scoremode = board_rec == NULL;
if (board_rec)
memset(board_rec,0,sizeof(BoardRec));
else {
board_rec = calloc(sizeof(BoardRec),1);
if (board_rec == NULL) {
fprintf(stderr,"Out of memory\n");
exit(1); } }
board->board->u_vdata =
board->board_frame->u_vdata=
board->status->u_vdata = board_rec;
board_rec->ox = board->board_frame->x;
board_rec->oy = board->board_frame->y;
board_rec->ow = board->board_frame->w;
board_rec->oh = board->board_frame->h;
board_rec->boardnumeditable= 1;
board_rec->board = board;
board_rec->seed = abs(seed)%1000000000;
initialize_new_board(board_rec->seed,board_rec->occ,board_rec->ideal,
board_rec->weight,board_rec->lookup);
board_rec->sel0 =
board_rec->sel1 = NIL;
board_rec->remain = 144;
board_rec->matchcount = match_count(board_rec->occ,board_rec->lookup,0);
board_rec->scoremode = scoremode;
board_rec->isfastgame = default_isfastgame;
memset(board_rec->inverted,NIL,sizeof(board_rec->inverted));
depth_scan_initialize(board_rec);
memset(&board_rec->infobox,0xAA,sizeof(InfoBoxRec));
fl_hide_object(board->pausebox);
update_info_box(board_rec);
deactivate_board_num(board_rec);
return(board_rec);
}
static __inline__ int find_tile(unsigned char *occ,int x,int y)
{
int i;
int best=NIL,maxdepth=NIL;
int ox,oy,ow,oh;
for (i = 144; i--;)
if ((maxdepth == NIL || maxdepth < board[i].depth) &&
tile_is_removable(occ,i)) {
tile_pos(i,&ox,&oy,&ow,&oh,0,0,0,0);
if (ox <= x && oy <= y && x < ox+ow && y < oy+oh) {
maxdepth = board[i].depth;
best = i; } }
return(best);
}
static void select_tile(BoardRec *board_rec,int tile)
{
unsigned char *occ = board_rec->occ;
unsigned char sel0 = board_rec->sel0;
unsigned char sel1 = board_rec->sel1;
int top,x,y,w,h;
if (tile == NIL || occ[tile] == NIL ||
((top = board[tile].top) != NIL && occ[top] != NIL))
return;
if (tile == sel0 || tile == sel1)
if (tile == sel0) board_rec->sel0 = NIL; else board_rec->sel1 = NIL;
else if (sel0 != NIL && occ[tile]/4 == occ[sel0]/4)
board_rec->sel1 = tile;
else if (sel1 != NIL && occ[tile]/4 == occ[sel1]/4)
board_rec->sel0 = tile;
else if (sel0 != NIL || sel1 != NIL)
return;
else
board_rec->sel0 = tile;
tile_pos(tile,&x,&y,&w,&h,0,0,0,0);
draw_area(x,y,w,h,board_rec);
XFlush(board_rec->disp);
return;
}
static void remove_tile(BoardRec *board_rec,int tile)
{
int x,y,w,h;
board_rec->history[board_rec->histpos] = board_rec->occ[tile];
if (++board_rec->histpos < 144)
board_rec->histstep[board_rec->histpos] =
board_rec->histstep[board_rec->histpos-1];
board_rec->occ[tile] = NIL;
board_rec->remain--;
tile_pos(tile,0,0,0,0,&x,&y,&w,&h);
if (board_rec->sel0 == tile) board_rec->sel0 = NIL;
else if (board_rec->sel1 == tile) board_rec->sel1 = NIL;
draw_area(x,y,w,h,board_rec);
XFlush(board_rec->disp);
return;
}
static void release_mouse_button(BoardRec *board_rec)
{
XEvent event;
do {
if (board_rec->depthscan.status == dsBusy)
depth_scan(board_rec);
else
usleep(50*1000l);
update_info_box(board_rec);
} while (!XCheckMaskEvent(board_rec->disp,ButtonReleaseMask,&event) ||
event.xbutton.state & ~(Button1Mask << (event.xbutton.button-1))
& (Button1Mask|Button2Mask|Button3Mask));
return;
}
void handle_mouse_push(int mx,int my,int key,BoardRec *board_rec)
{
unsigned char tile1,tile2;
deactivate_board_num(board_rec);
switch (key) {
case 1:
if ((tile1 = find_tile(board_rec->occ,mx,my)) != NIL) {
select_tile(board_rec,tile1);
release_mouse_button(board_rec);
if (board_rec->sel0 != NIL && board_rec->sel1 != NIL) {
board_rec->histstep[board_rec->histpos] = board_rec->histpos;
for (;;) {
remove_tile(board_rec,board_rec->sel0);
remove_tile(board_rec,board_rec->sel1);
board_rec->matchcount = match_count(board_rec->occ,
board_rec->lookup,NULL);
update_info_box(board_rec);
if (!board_rec->isfastgame || !board_rec->remain ||
!find_unambiguous(board_rec,board_rec->occ,&tile1,&tile2))
break;
board_rec->scoremode = 0;
select_tile(board_rec,tile1);
select_tile(board_rec,tile2); }
if (!board_rec->time && board_rec->matchcount)
board_rec->time =time(NULL);
else if (board_rec->time > 0 && !board_rec->matchcount)
if ((board_rec->time-=time(NULL)) == 0)
board_rec->time =-1;
if (board_rec->depthscan.status != dsFail)
depth_scan_initialize(board_rec);
update_info_box(board_rec); } }
break;
case 2:
if (!board_rec->matchcount)
release_mouse_button(board_rec);
else {
unsigned char inverted[144],sel;
#if DRAWSUGGEST == 1
int tile;
#endif
if ((sel = board_rec->sel0) != NIL ||
(sel = board_rec->sel1) != NIL)
select_tile(board_rec,sel);
match_count(board_rec->occ,board_rec->lookup,board_rec->inverted);
memcpy(inverted,board_rec->inverted,sizeof(inverted));
board_rec->scoremode = 0;
if (board_rec->time == 0)
board_rec->time = time(NULL);
#if DRAWSUGGEST == 1
for (tile = 144; tile--; )
if (inverted[tile] != NIL) {
int x,y,w,h;
tile_pos(tile,&x,&y,&w,&h,0,0,0,0);
draw_area(x,y,w,h,board_rec); }
#else
draw_all_tiles(board_rec);
#endif
update_info_box(board_rec);
release_mouse_button(board_rec);
memset(board_rec->inverted,NIL,sizeof(board_rec->inverted));
#if DRAWSUGGEST == 1
for (tile = 144; tile--; )
if (inverted[tile] != NIL) {
int x,y,w,h;
tile_pos(tile,&x,&y,&w,&h,0,0,0,0);
draw_area(x,y,w,h,board_rec); }
#else
draw_all_tiles(board_rec);
#endif
if (sel != NIL)
select_tile(board_rec,sel); }
break;
case 3: {
int i;
if ((i = board_rec->sel0) != NIL ||
(i = board_rec->sel1) != NIL)
select_tile(board_rec,i);
release_mouse_button(board_rec);
break; }
default:
break; }
return;
}
void game_undo_move(BoardRec *board_rec)
{
int i,p,x,y,w,h;
deactivate_board_num(board_rec);
if ((i = board_rec->sel0) != NIL ||
(i = board_rec->sel1) != NIL)
select_tile(board_rec,i);
if (board_rec->remain == 144)
return;
if (board_rec->time <= 0)
if ((board_rec->time += time(NULL)) == 0)
board_rec->time = 1;
board_rec->scoremode = 0;
while (board_rec->remain != 144) {
p = --board_rec->histpos;
i = board_rec->lookup[board_rec->history[p]];
board_rec->occ[i] = board_rec->history[p];
tile_pos(i,0,0,0,0,&x,&y,&w,&h);
draw_area(x,y,w,h,board_rec);
if (board_rec->remain++ & 1) {
board_rec->matchcount=match_count(board_rec->occ,board_rec->lookup,NULL);
update_info_box(board_rec); }
if (p == board_rec->histstep[p])
break; }
depth_scan_initialize(board_rec);
update_info_box(board_rec);
return;
}
void handle_status_push(int key,BoardRec *board_rec)
{
int i;
if (key != 1) {
handle_mouse_push(-1,-1,key,board_rec);
return; }
deactivate_board_num(board_rec);
if (!board_rec->remain ||
(board_rec->depthscan.status != dsSuccess &&
board_rec->depthscan.status != dsSuccessSelected))
return;
board_rec->depthscan.status = dsSuccessSelected;
board_rec->scoremode = 0;
if (!board_rec->time)
board_rec->time = time(NULL);
if ((i = board_rec->sel0) != NIL ||
(i = board_rec->sel1) != NIL)
select_tile(board_rec,i);
select_tile(board_rec,board_rec->ideal[board_rec->remain-1]);
select_tile(board_rec,board_rec->ideal[board_rec->remain-2]);
release_mouse_button(board_rec);
board_rec->histstep[board_rec->histpos] = board_rec->histpos;
board_rec->depthscan.status = dsSuccess;
for (;;) {
remove_tile(board_rec,board_rec->sel0);
remove_tile(board_rec,board_rec->sel1);
board_rec->matchcount = match_count(board_rec->occ,board_rec->lookup,NULL);
update_info_box(board_rec);
if (!board_rec->isfastgame || !board_rec->remain ||
!find_unambiguous(board_rec,board_rec->occ,
&board_rec->sel0,&board_rec->sel1))
break;
board_rec->depthscan.status = dsBusy; }
if (!board_rec->matchcount)
if (board_rec->time > 0) {
if ((board_rec->time -= time(NULL)) == 0)
board_rec->time = -1; }
else if (board_rec->time == 0)
board_rec->time = -1;
if (board_rec->depthscan.status != dsSuccess)
depth_scan_initialize(board_rec);
update_info_box(board_rec);
return;
}